package com.example.rentingapp.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.example.rentingapp.R;

public class ParentCategoryAdapter extends BaseAdapter {
    private LayoutInflater mInflater;//布局加载器
    private Context mContext;
    private String[] mData;//筛选条件数据
    private int position;//位置

    public ParentCategoryAdapter(Context context, String[] Data) {
        this.mContext = context;
        this.mData = Data;
        mInflater = LayoutInflater.from(context);
    }

    @Override
    public int getCount() {
        return mData.length;
    }

    @Override
    public Object getItem(int position) {
        return null;
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup viewGroup) {
        ViewHolder holder = null;
        if (convertView == null) {
            convertView = mInflater.inflate(R.layout.common_popup_list_item, null);
            holder = new ViewHolder();
            holder.mTitleTv = (TextView) convertView.findViewById(R.id.tv_common_pop_title);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }
        holder.mTitleTv.setText(mData[position]);
        return convertView;
    }

    public class ViewHolder {
        //筛选项文字tv
        TextView mTitleTv;
    }

    public void setSelectedPosition(int position) {
        this.position = position;
    }

    public int getPos() {
        return position;
    }
}
